package com.zj.weather.bgviews.light;

import android.content.Context;
import android.graphics.ComposePathEffect;
import android.graphics.CornerPathEffect;
import android.graphics.DiscretePathEffect;
import android.graphics.MaskFilter;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.graphics.Point;
import android.graphics.PointF;
import android.os.Build;

import com.zj.weather.utils.DebugUtils;
import com.zj.weather.utils.DisplayUtils;

import static android.os.Build.VERSION_CODES.KITKAT;
import static com.zj.weather.utils.RandomUtils.getRandom;

/**
 * Created by zhaojie on 2018/8/14.
 */

public class LightUtils {

    public static Paint getEffectPaint(Context c, int curAlpha, float width, float minStepInterval, float maxStepInterval, float maxDeviation, MaskFilter filter, boolean isAddEffect) {
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        paint.setStyle(Paint.Style.STROKE);
        paint.setColor(0xffffe6ff);
        paint.setAlpha(curAlpha);
        paint.setStrokeCap(Paint.Cap.ROUND);
        paint.setDither(true);
        paint.setStrokeWidth(width);
        if (isAddEffect) {
            float interval = DisplayUtils.dip2px(c, getRandom(minStepInterval, maxStepInterval));
            CornerPathEffect cpe = new CornerPathEffect(0.25f * interval);
            DiscretePathEffect dpe = new DiscretePathEffect(interval, getRandom(0.0f, 1.0f) * DisplayUtils.dip2px(c, maxDeviation));
            ComposePathEffect composePathEffect = new ComposePathEffect(cpe, dpe);
            paint.setPathEffect(composePathEffect);
        } else {
            float interval = DisplayUtils.dip2px(c, getRandom(minStepInterval, maxStepInterval));
            CornerPathEffect cpe = new CornerPathEffect(0.25f * interval);
            paint.setPathEffect(cpe);
        }
        paint.setMaskFilter(filter);
        return paint;
    }

}
